﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace HYElectricSetting
{
	public partial class CreateWireSizeForm : System.Windows.Forms.Form
	{
		public string Section { get; set; }

		public string Ampacity { get; set; }

		public CreateWireSizeForm(string title, string section, string ampacity, List<string> keys)
		{
			this.InitializeComponent();
			this.formTitle = title;
			this.Section = section;
			this.Ampacity = ampacity;
			this.defaultSection = section;
			this.keySet = keys;
		}

		private void CreateWireSizeForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			this.Text = this.formTitle;
			this.txtSection.IsNumber = InputSelection.number;
			this.txtSection.IsPositive = SymbolSelect.positive;
			this.txtSection.IsInt = NumberType.doubles;
			this.textAmpacity.IsNumber = InputSelection.number;
			this.textAmpacity.IsPositive = SymbolSelect.positive;
			this.textAmpacity.IsInt = NumberType.integer;
			this.txtSection.Text = this.Section;
			this.textAmpacity.Text = this.Ampacity;
			this.txtSection.Focus();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.Section = StringTools.RemoveZero(this.txtSection.Text.Trim());
			this.Ampacity = StringTools.RemoveZero(this.textAmpacity.Text.Trim());
			bool flag = string.IsNullOrEmpty(this.Section) || string.IsNullOrEmpty(this.Ampacity);
			if (flag)
			{
				TaskDialog.Show("盈建科提示", "导线截面积，载流量的值都不能为空。");
				bool flag2 = string.IsNullOrEmpty(this.Section);
				if (flag2)
				{
					this.txtSection.Focus();
				}
				else
				{
					this.textAmpacity.Focus();
				}
			}
			else
			{
				bool flag3 = this.Section != this.defaultSection && this.keySet.Contains(this.Section);
				if (flag3)
				{
					TaskDialog.Show("盈建科提示", "此导线截面积已存在。请指定唯一名称。");
					this.txtSection.Focus();
				}
				else
				{
					base.DialogResult = DialogResult.OK;
				}
			}
		}

		private string formTitle;

		public string defaultSection;

		private List<string> keySet;
	}
}
